from pydantic import BaseModel, Field
from typing import Optional

class Token(BaseModel):
    """访问令牌模式"""
    access_token: str = Field(..., description="访问令牌")
    refresh_token: str = Field(..., description="刷新令牌")
    token_type: str = Field(default="bearer", description="令牌类型")
    expires_in: int = Field(..., description="过期时间(秒)")

class TokenData(BaseModel):
    """令牌数据模式"""
    username: Optional[str] = Field(None, description="用户名")
    user_id: Optional[int] = Field(None, description="用户ID")
    scopes: list[str] = Field(default=[], description="权限范围")

class RefreshToken(BaseModel):
    """刷新令牌模式"""
    refresh_token: str = Field(..., description="刷新令牌")

class TokenResponse(BaseModel):
    """令牌响应模式"""
    access_token: str
    refresh_token: str
    token_type: str = "bearer"
    expires_in: int
    user_info: dict = Field(..., description="用户信息")